import 'package:flutter/material.dart';
import 'package:hospitable_rental/pages/home/search/room_item.dart';
import 'package:hospitable_rental/pages/home/search/room_item_widget.dart';
import 'package:hospitable_rental/routes/routes.dart';
import 'package:hospitable_rental/widgets/common_floating_action_button.dart';

class RoomsManagePage extends StatelessWidget {
  final List _tabs = ["已租", "空置"];

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: _tabs.length,
      initialIndex: 0,
      child: Scaffold(
        appBar: AppBar(
          title: Text("房屋管理"),
          bottom: TabBar(
            tabs: _tabs.map((e) => Tab(text: e)).toList(),
          ),
        ),
        body: TabBarView(
          children: _tabs
              .map(
                (e) => ListView.builder(
                  itemCount: roomItemList.length,
                  itemBuilder: (BuildContext context, int index) {
                    return RoomItemWidget(roomItemList[index]);
                  },
                ),
              )
              .toList(),
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
        floatingActionButton: CommonFloatingActionButton(
          "发布房源",
          onTap: () => Navigator.of(context).pushNamed(Routes.roomPublish),
        ),
      ),
    );
  }
}
